{include file="public/header" /}



<div class="page">

    <div class="fixed-empty"></div>
    <form id="adv_form" enctype="multipart/form-data" method="post" name="advForm">
        <table class="ds-default-table">
            <tbody>
            <tr class="noborder">
                <td class="required w120"><label class="validation" for="adv_name">{$Think.lang.adv_name}:</label></td>
                <td class="vatop rowform"><input type="text" name="adv_name" id="adv_name" class="txt" value="{$adv.adv_title|default=''}"></td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required"><label>所属分类:</label></td>
                <td class="vatop rowform">
                    <select name="ap_id" id="ap_id">
                        {foreach name="ap_list" item="ap" key="ap_k" }
                        <option value='{$ap.ap_id}' {if condition="$Request.param.ap_id eq $ap.ap_id || $adv.ap_id eq $ap.ap_id"}selected{/if}>
                        {if condition="($ap.ap_name==1)"}视频广告
                        {elseif condition="($ap.ap_name==2)"}商品促销
                        {elseif condition="($ap.ap_name==3)"}项目定制
                        {elseif condition="($$ap.ap_name==4)"}文章类
                        {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required"><label for="adv_startdate">{$Think.lang.ds_start_time}:</label></td>
                <td class="vatop rowform"><input type="text" name="adv_startdate" id="adv_startdate" class="txt date" value="{:date('Y-m-d',$adv.adv_startdate)}"></td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required"><label for="adv_startdate">{$Think.lang.adv_sort}:</label></td>
                <td class="vatop rowform"><input type="text" name="adv_sort" id="adv_sort" class="txt" value="{$adv.adv_sort|default='0'}">
                </td>
                <td class="vatop tips">{$Think.lang.adv_sort_role}</td>
            </tr>
            <tr class="noborder">
                <td class="required"><label for="adv_startdate">{$Think.lang.adv_enabled}:</label></td>
                <td class="vatop rowform">
                    <div class="onoff">
                        <label for="adv_enabled1" class="cb-enable {if condition="$adv.adv_enabled eq 1"}selected{/if}">{$Think.lang.ds_open}</label>
                        <label for="adv_enabled0" class="cb-disable {if condition="$adv.adv_enabled eq 0"}selected{/if}">{$Think.lang.ds_close}</label>
                        <input id="adv_enabled1" name="adv_enabled" value="1" type="radio" {if condition="$adv.adv_enabled eq 1"} checked="checked"{/if}>
                        <input id="adv_enabled0" name="adv_enabled" value="0" type="radio" {if condition="$adv.adv_enabled eq 0"} checked="checked"{/if}>
                    </div>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder">
                <td class="required"><label for="adv_enddate">{$Think.lang.ds_end_time}:</label></td>
                <td class="vatop rowform"><input type="text" name="adv_enddate" id="adv_enddate" class="txt date" value="{:date('Y-m-d',$adv.adv_enddate)}"></td>
                <td class="vatop tips"></td>
            </tr>
            <tr class="noborder"  id="video_type">
                <td class="required w120">视频:</td>
                <td class="vatop rowform">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <video width="300" height="300" controls>
                                <source src="{$http_name}/{$ap.videos}" type="video/mp4">
                            </video>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                    <div id="dataLoading" class="wp_data_loading">
                        <div class="data_loading"></div>
                    </div>
                    <div id="demo">
                    </div>
                </td>
            </tr>
            <!--        <tr id="adv_code" class="noborder">-->
            <!--            <input type="hidden" name="mark" value="0">-->
            <!--            <td class="required"><label for="file_adv_code">{$Think.lang.adv_img_upload}:</label></td>-->
            <!--            <td class="vatop rowform">-->
            <!--                {notempty name="$adv.adv_code"}-->
            <!--                    <div class=""><img width="300px" height="200px"src="{$Think.BASE_SITE_ROOT}/uploads/{$Think.ATTACH_ADV}/{$adv.adv_code|default=''}"></div>-->
            <!--                {/notempty}-->
            <!--                <span class="type-file-box">-->
            <!--                    <input type='text' name='textfield' id='textfield1' class='type-file-text' />-->
            <!--                    <input type='button' name='button' id='button1' value='' class='type-file-button' />-->
            <!--                    <input name="adv_code" id="file_adv_code" type="file" class="type-file-file" id="site_logo" size="30" hidefocus="true">-->
            <!--                </span>-->
            <!--            </td>-->
            <!--          <td class="vatop tips">{$Think.lang.adv_edit_support}gif,jpg,jpeg,png </td>-->
            <!--        </tr>-->
            </tbody>
            <tfoot>
            <tr class="tfoot" style="text-align: center;">
                <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<link href="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.css" rel="stylesheet" type="text/css">
<script src="{$Think.PLUGINS_SITE_ROOT}/colorpicker/evol.colorpicker.min.js"></script>
<script type="text/javascript">
    $(function(){
        $('#adv_startdate').datepicker({dateFormat: 'yy-mm-dd'});
        $('#adv_enddate').datepicker({dateFormat: 'yy-mm-dd'});
        $('#adv_bgcolor').colorpicker({showOn: 'both'});
        $("#file_adv_code").change(function () {
            $("#textfield1").val($("#file_adv_code").val());
        });
    });
</script>

<script>
    //按钮先执行验证再提交表单
    $(function(){
        $('#adv_form').validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules : {
                adv_name : {
                    required : true
                }
            },
            messages : {
                adv_name : {
                    required : '{$Think.lang.ap_can_not_null}'
                }

            }
        });

        $(document).on('change', '#videos', function () {

            $('#dataLoading').show();
            var files = document.getElementById('videos').files[0];
            var formData = new FormData();
            var obj = $(this);
            formData.append('file', files);
            var url = $(this).attr('data-action');
            $.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: url,
                data: formData,
                cache: false,  //默认是true，但是一般不做缓存
                processData: false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                contentType: false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                //请求成功
                success: function (result) {
                    console.log(result);return  a
                    if (result.msg == 1) {
                        $('.vide').empty();
                        $('#dataLoading').hide();
                        layer.msg('上传成功');
                        $("#video_name").val(result.files_name);
                        // $("type[name='old_filename']").val(result.old_name);
                    } else {
                        obj.val('');
                        $('#dataLoading').hide();
                        layer.msg('文件信息错误,请重新上传');
                        return false;
                    }

                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });

        });
    });


    $((function($){

        $.datepicker.regional['zh-CN'] = {

            clearText: '清除',

            clearStatus: '清除已选日期',

            closeText: '关闭',

            closeStatus: '不改变当前选择',

            prevText: '<上月',

            prevStatus: '显示上月',

            prevBigText: '<<',

            prevBigStatus: '显示上一年',

            nextText: '下月>',

            nextStatus: '显示下月',

            nextBigText: '>>',

            nextBigStatus: '显示下一年',

            currentText: '今天',

            currentStatus: '显示本月',

            monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],

            monthNamesShort: ['一','二','三','四','五','六', '七','八','九','十','十一','十二'],

            monthStatus: '选择月份',

            yearStatus: '选择年份',

            weekHeader: '周',

            weekStatus: '年内周次',

            dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],

            dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],

            dayNamesMin: ['日','一','二','三','四','五','六'],

            dayStatus: '设置 DD 为一周起始',

            dateStatus: '选择 m月 d日, DD',

            dateFormat: 'yy-mm-dd',

            firstDay: 1,

            initStatus: '请选择日期',

            showMonthAfterYear:true,//是否把月放在年的后面

            yearSuffix: '年', //年的后缀

            isRTL: false

        };

        $.datepicker.setDefaults($.datepicker.regional['zh-CN']);

    })(jQuery));
</script>